<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <!-- 如果需要使用 Thymeleaf 的语法,则需要添加一个名称空间 -->
    <meta charset="UTF-8" xmlns:th="http://www.thymeleaf.org">
    <base th:href="@{/}">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>base</title>
    <style>
        table{
            border-collapse: collapse;
        }
        td{
            border: 2px solid #ccc;
            padding: 5px;
        }
    </style>
</head>
<body>
    <p>if语法</p>
    <p th:text="${msg}"></p>
    <p th:if="${#strings.length(msg) > 5}">msg的数据长度大于5 1</p>
    <p th:if="${not (#strings.length(msg) > 5)}">msg的数据长度不大于5</p>
    <p th:if="${#strings.length(msg) <= 5}">msg的数据长度不大于5</p>
    <p th:unless="${#strings.length(msg) > 5}">msg的数据长度不大于5</p>
    <hr>
    <p>switch语法</p>
    <div th:switch="${#strings.length(msg)}">
        <p th:case="1">长度为1</p>
        <p th:case="2">长度为2</p>
        <p th:case="3">长度为3</p>
        <p th:case="4">长度为4</p>
        <p th:case="5">长度为5</p>
    </div>
    <p>for语法</p>
    <ul>
        <li th:each="name,status : ${nameList}" th:text="${name}"></li>
    </ul>
    <hr>
    <table>
        <tr>
            <td>序号</td>
            <td>编号</td>
            <td>姓名</td>
            <td>性别</td>
            <td>工资</td>
        </tr>
        <tr th:each="emp,status : ${employeeList}">
            <td th:text="${status.index}"></td>
            <td th:text="${emp.id}"></td>
            <td th:text="${emp.name}"></td>
            <td th:text="${emp.gender == 0 ? '男':'女'}"></td>
            <td th:text="${emp.salary}"></td>
        </tr>
    </table>
</body>
</html>
